//---------------------------------------------------------------------
//  This file is part of the Background Motion solution.
// 
//  Copyright (C) Mindscape (TM).  All rights reserved.
//  http://www.mindscape.co.nz
// 
//  THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//---------------------------------------------------------------------

using Mindscape.BackgroundMotion.Model;
using Mindscape.BackgroundMotion.Website.Controllers;
using Mindscape.BackgroundMotion.Website.Infrastructure;
using Mindscape.BackgroundMotion.Website.Presenters.Interfaces;
using Mindscape.BackgroundMotion.Website.Views;

namespace Mindscape.BackgroundMotion.Website
{
  /// <remarks>
  /// Name is MemberDetails to avoid conflict with naming of the model
  /// </remarks>
  public partial class MemberDetails : PageBase<MemberPresenter, IMemberView, IMembershipController>, IMemberView
  {
    private Member _member;
    private SearchResult _memberContributions;
    private SearchResult _unmoderatedContributions;
    private bool _hasUnapprovedContributions = false;
   
    /// <summary>
    /// A set of results which represent the contributions made by this member
    /// </summary>
    public SearchResult MemberContributions
    {
      get
      {
        return _memberContributions;
      }
      set
      {
        _memberContributions = value;
        ContributionGrid.Contributions = value.Contributions;
        PagingControl.SearchResults = value;
      }
    }

    /// <summary>
    /// A set of results which represents the contributions of the member which aren't yet approved
    /// </summary>
    public SearchResult MemberUnapprovedContributions
    {
      get
      {
        return _unmoderatedContributions;
      }
      set
      {
        _unmoderatedContributions = value;
        UnapprovedContributionGrid.Contributions = value.Contributions;
      }
    }

    /// <summary>
    /// Gets a value indicating whether this instance has contributions.
    /// </summary>
    /// <value>
    /// 	<c>true</c> if this instance has contributions; otherwise, <c>false</c>.
    /// </value>
    public bool HasContributions
    {
      get
      {
        if (_memberContributions.Contributions.Count == 0)
        {
          return false;
        }
        else
        {
          return true;
        }
      }
    }

    /// <summary>
    /// Gets a value indicating whether this instance has unmoderated contributions
    /// </summary>
    /// <remarks>This can only be true if being viewed by the member that submitted the contributions</remarks>
    public bool HasUnapprovedContributions
    {
      get { return _hasUnapprovedContributions; }
      set { _hasUnapprovedContributions = value; }
    }

    /// <summary>
    /// The requested member instance
    /// </summary>
    /// <value></value>
    public Member Member
    {
      get
      {
        return _member;
      }
      set
      {
        _member = value;
        DataBinder.DataBind();
      }
    }
  }
}
